#
#    Copyright (C) 2016 Francisco Javier Parra <franparpe@openmailbox.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

from PyQt5 import QtCore

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s


def checkPressureAngle(pressureAngleList):
    PAngleIsCorrect = True
    i = 0
    while (i < len(pressureAngleList)) and PAngleIsCorrect:
        if abs(pressureAngleList[i]) > 30:
            PAngleIsCorrect = False

        i += 1

    if PAngleIsCorrect:
        message = _fromUtf8("Acceptable")
    else:
        message = _fromUtf8("Not acceptable")

    return PAngleIsCorrect, message
